package com.model;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class LogAop {

    @Pointcut(value = "execution(* com.model.*Service.*(..))")
    public void point(){};

    @AfterReturning(value = "point()")
    public void Log(JoinPoint joinPoint){
        System.out.println("执行"+joinPoint.getSignature()+"方法");
    }

    @Around( value = "point()")
    public Object tag(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
        long start = System.currentTimeMillis();
        Object obj = proceedingJoinPoint.proceed();
        long end = System.currentTimeMillis();
        System.out.println("该方法执行了"+String.valueOf(end-start));
        return obj;
    }
}
